package com.zhengxyou.jetpackdemo.dataBinding;

import java.text.SimpleDateFormat;
import java.util.Date;

import androidx.databinding.InverseMethod;

//https://blog.csdn.net/qiang_xi/article/details/75379321
//https://blog.csdn.net/qiang_xi/article/details/77586836
public class Converter {
    @InverseMethod("stringToDate")
    public static String dateToString(long value) {
        return new SimpleDateFormat().format(new Date(value));
    }

    public static long stringToDate(String value) {
        try {
            return Long.parseLong(value);
        } catch (Exception e) {
            return System.currentTimeMillis();
        }
    }
}
